<?php
use models\Factory;
use util\CommonUtil;
include '../autoload.php';
require_once('../vendor/autoload.php');

header("Content-Type: text/html; charset=UTF-8");
ini_set('memory_limit','2650M');

//抓取第三方评论数据........
set_time_limit(0);

$ua = CommonUtil::getPcUserAgent();
if (empty($ua)) {
    CommonUtil::echoStr("\nUA初始化失败，执行下次任务\n");
    exit();
}

//CommonUtil::switchIP(); //重启路由，更换IP。。

try {




    $urls = [
        'https://www.nuomi.com/deal/b00ulk6bh.html#nav-bar'
    ];

    //var_dump($urls);

    foreach ($urls as $url) {

        CommonUtil::echoStr("\n抓取页面：{$url}\n");

        $spider = Factory::getSpider($url, $ua);
        if (empty($spider)){
            CommonUtil::echoStr("\nspider为空\n");
        }
        $comments = $spider->getComments(); //评论列表
        var_dump($comments);

        CommonUtil::echoStr("\n---------------------------------------------------\n");
    }

} catch (\Exception $e) {

    CommonUtil::logException($e);   //记录异常信息
    CommonUtil::echoStr($msg = "\n发生异常，过滤本次任务~\n");
}

//释放内存
if (!empty($productStr)) unset($productStr);
if (!empty($productArr)) unset($productArr);
if (!empty($spider)) unset($spider);
if (!empty($comments)) unset($comments);
if (!empty($post_data)) unset($post_data);


?>